package com.leejxx.admin.controller.v1;

import com.leejxx.admin.service.AdChannelService;
import com.leejxx.model.admin.dtos.AdChannel;
import com.leejxx.model.admin.dtos.ChannelDto;
import com.leejxx.model.admin.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author LeeJx
 * @ClassName AdChannelController
 * @Description TODO
 * @date 2021/2/4 14:21
 * @Version 1.0
 */
@RestController
@RequestMapping("/api/v1/channel")
public class AdChannelController {

    @Autowired
    private AdChannelService adChannelService;

    @RequestMapping("/list")
    public ResponseResult findByNameAndPage(@RequestBody ChannelDto channelDto) {
        return adChannelService.findByNameAndPage(channelDto);
    }

    @RequestMapping("/save")
    public ResponseResult saveChannel(@RequestBody AdChannel adChannel) {
        return adChannelService.saveChannel(adChannel);
    }

    @RequestMapping("/update")
    public ResponseResult updateChannel(@RequestBody AdChannel adChannel) {
        return adChannelService.updateChannel(adChannel);
    }

    @RequestMapping("/delete/{id}")
    public ResponseResult deleteChannel(@PathVariable String id) {
        return adChannelService.deleteChannelById(id);
    }
}
